Ext.define('PJ.view.attendancemanagement.List', {
    extend: 'AM.default.DefaultList',
    alias: ['widget.attendancemanagementList'],
    requires: ['AM.default.DefaultSearchForm',
               'AM.default.DateTime', 
               'AM.default.DefaultDateField',
               'AM.default.DefaultDoubleDateField',
               'AM.default.jsonp.DefaultLoadJsonp',//jsonp加载数据
		       'AM.default.DefaultActiveStateCombo',
		       'PJ.view.attendancemanagement.SeeparticipatingList'
               ],
   selModel: {
       selType: '',
       // 设置为只能通过复选框选中行
       checkOnly: true
   },
    initComponent: function(){
    	var me= this;
    	this.columns = [{
    		header: '培训班编号',
    		dataIndex: 't.classNum',
    		width: 120,
    		renderer: function(value, meta, record){
    			meta.style = "white-space:normal;cursor: pointer;color:blue;";
    			meta.tdAttr = "data-qtip='" + value + "' classId=" + record.get("classId");
    			return value;
    		},
    		listeners: {
    			click: function(g, clm){
    				var classId = clm.getAttribute("classId");
    				win = Ext.create('PJ.view.trainingmanagement.Edit', {
    					title: "查看培训班",
    					flag:4,
    					grid: me,
    					isDisable:false,
    					isReadOnly:true,
    					classId:classId,
    					isHideExpectTime: false
    				}).show();
    				var actionName = "load";
    				if(gj_onlineLearning_constant.loadType == "jsonp"){
    					actionName = "loadJsonp";
    				}
    				win.down("form").getForm().doAction(actionName,{
    					url:me.store.preUpdateUrl,
    					params:{
    						classId: classId
    					},
    					success:function(f,action){
    						var data = action.response.responseText;
    	        			var json = gj_onlineLearning_constant.loadType=="ajax" ? Ext.decode(data, true) : action.response;
    	        			var form = win.down('form');	 
    	        			var baseForm = form.getForm();
    	        			baseForm.findField("classNum").setValue(json.data.classNum);
    	        			baseForm.findField("classNum_").setValue(json.data.classNum);
    					}
    				});

    			}
    		}
    	},{
            header: '培训班名称',
            dataIndex: 't.className',
            flex: 1,
            minWidth: 120,
    		renderer: function(value, metaData, record){
    			metaData.tdAttr = 'data-qtip="' + value + '"';
    			return value;
    		}
        },{
            header: '承办部委',
            dataIndex: 't.ministrieName',
            width: 120,
    		renderer: function(value, metaData, record){
    			metaData.tdAttr = 'data-qtip="' + value + '"';
    			return value;
    		}
        },{
            header: '开班时间',
            dataIndex: 't.beginDate',
            width: 80 
        },{
            header: '结业时间',
            dataIndex: 't.endDate',
            width: 80 
        },{
        	header: '参训率',
        	dataIndex: 'attendanceRateStr',
        	width: 80,
    		renderer: function(value, meta, record){
    			meta.style = "white-space:normal;cursor: pointer;color:blue;";
    			meta.tdAttr = "data-qtip='" + value + "' classId=" + record.get("classId");
    			return value;
    		},
    		listeners: {
    			click: function(g, clm){
    				var classId = clm.getAttribute("classId");
    				Ext.create('AM.default.DefaultWindowView', {
    		            title: "参训人员管理",
    		            height:550,
    		            width: 900,
    		            grid: me,
    		            classId: classId,
    		            items: [{
    		                xtype: 'seeparticipatingList'
    		            }],
    		            listeners: {
    		            	close: function(){
    		            		me.getStore().load();
    		            	}
    		            }
    		        });
    			}
    		}
        }];
    	
        this.store = Ext.create('PJ.'+ prototype +'.attendancemanagement.List',{
        	isLoad: true
        });
        this.callParent(arguments);
        this.loadType = gj_onlineLearning_constant.loadType;//加载方式
    },
    //预览
    listeners: {
		viewready: function(){
			var me = this;
			this.addDocked([{
				dock: 'top',
				xtype: "searchform",
				columnCount: 3,
				fieldDefaults: {
					labelAlign: 'right',
					labelWidth: 100
				},
				items: [{
					xtype: "textfield",
					fieldLabel: '培训班编号',
					name: "searchTrainingNum",
					maxLength: "50",
					emptyText: "请输入培训班编号"
				},{
					xtype: "textfield",
					fieldLabel: '培训班名称',
					name: "searchClassName",
					maxLength: "50",
					emptyText: "请输入培训班名称"
				},{
					xtype: "textfield",
					fieldLabel: '承办部委',
					name: "searchMinistrieName",
					maxLength: "50",
					emptyText: "请输入承办部委"
				}, {
    				xtype: 'defaultDate',
    				fieldLabel: '开班时间',
    				name: 'searchBeginDate',
    				id: 'searchTrainingManagementSDKQ',
    				vtype: 'startLessEndDate',
    				startLessEndDate: {
    					targetCmpId: 'searchTrainingManagementEDKQ',
    					isStart: true
    				},
    				emptyText: "请输入开班时间"
    			}, {
    				xtype: 'defaultDate',
    				fieldLabel: '结业时间',
    				labelSeparator: '',
    				name: 'searchEndDate',
    				id: 'searchTrainingManagementEDKQ',
    				vtype: 'startLessEndDate',
    				vtypeText: '结束时间不能早于开始时间！',
    				startLessEndDate: {
    					targetCmpId: 'searchTrainingManagementSDKQ',
    					isStart: false
    				},
    				emptyText: "请输入结业时间"
    			}],
				grid: this
			}]);
            // 触发权限过滤事件
            me.fireEvent("permission", this);
		}
    }
});
